package com.thz.system.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.File;

/**
 * 文档转换配置
 */
@Data
@Component
@ConfigurationProperties(prefix = "document.converter")
public class DocumentConverterProperties {

    /**
     * LibreOffice 可执行文件路径
     */
    private String libreofficePath = "soffice";

    /**
     * 转换超时时间（秒）
     */
    private long timeoutSeconds = 180;

    /**
     * 最大并发转换数
     */
    private int maxConcurrency = 1;

    /**
     * 临时目录
     */
    private String tempDir = System.getProperty("java.io.tmpdir");

    public File resolveTempDir() {
        File dir = new File(tempDir);
        if (!dir.exists()) {
            dir.mkdirs();
        }
        return dir;
    }

    public boolean isLibreOfficeConfigured() {
        return libreofficePath != null && !libreofficePath.isBlank();
    }
}

